'''
The Customer User Interface for the coffee bar workflow (Winter Intensives Lab 5)

This is where you define the fields that appear on the screen (application) the Customer
sees and tell WMP how this application (user interface) fits into the overall workflow.

Note:  the comments here assume you have already read through the comments
in CoffeeBackend.py and OrderTakerApplication.py and made your edits there.
'''

from frontend.roleApplication import RoleApplication
from frontend.form import Type
import winsound,sysconfig

def music(filename):
    winsound.PlaySound('%s' % filename, winsound.SND_FILENAME)

class CustomerApplication(RoleApplication):
    '''
    The CustomerApplication "class" is a collection of the "methods" (functions) that 
    define the elements of the order taker application.  
    
    An application will always include the method __init__ and at least one
    method to define a form that the user of this application will use.
    '''

    def __init__(self):
        '''
        Declare this application to be part of a given work flow and specify its role in that workflow.
        '''
        # Declare this application to be part of a given workflow, and responsible for a given role:
        # !!! Modify the following to use the actual work flow name and role name you need...
        super(CustomerApplication, self).__init__("Panera", "Customer") 
        
        # Declare any tasks that this role is able to perform:
        # !!! Modify to use actual task name and name_fields:
        #self.register_sink_step("EnterOrder", self.enter_order_form_creator, name_fields=["sequence", "FirstName", "FoodOrder", "PaymentInfo"])
        self.register_source_step("EnterOrder", self.enter_order_form_creator) 
        self.register_sink_step("GetFeedback", self.get_feedback_form_creator) 


    def enter_order_form_creator(self, stepname, form):

        ### STEP 1: DISPLAY MENU
        music("13seconds.wav")
        
        '''
        Defines the data entry form for the Customer application.
        This form appears once the Customer selects one of the pending orders from a list.
        '''
        # !!! Use one or more fields from order to define label...
        form.add_static_label('Please provide the customer name:') 
        form.add_field(Type.SHORTSTRING, "FirstName", labeltext="First Name")
        form.add_field(Type.SHORTSTRING, "LastName", labeltext="Last Name")
        form.add_static_label('What do you want to order for your first item?')
        form.add_field(Type.CHOICE, "Item1",choices=['', 'Sierra Turkey', 'Bagel and Cream Cheese', 'Mac and Cheese', 'Chicken Caesar', 'Chicken Noodle Soup', 'Smoothie'], labeltext="Item One")
        form.add_static_label('What do you want to order for your second item?')
        form.add_field(Type.CHOICE, "Item2",choices=['', 'Sierra Turkey', 'Bagel and Cream Cheese', 'Mac and Cheese', 'Chicken Caesar', 'Chicken Noodle Soup', 'Smoothie'], labeltext="Item Two")
        form.add_static_label('What do you want to order for your third item?')
        form.add_field(Type.CHOICE, "Item3",choices=['', 'Sierra Turkey', 'Bagel and Cream Cheese', 'Mac and Cheese', 'Chicken Caesar', 'Chicken Noodle Soup', 'Smoothie'], labeltext="Item Three")
        form.add_static_label('What do you want to order for your fourth item?')
        form.add_field(Type.CHOICE, "Item4",choices=['', 'Sierra Turkey', 'Bagel and Cream Cheese', 'Mac and Cheese', 'Chicken Caesar', 'Chicken Noodle Soup', 'Smoothie'], labeltext="Item Four")
        form.add_static_label('Do you have any food allergies?')
        form.add_field(Type.SHORTSTRING, "FoodAllergies", labeltext="Food Allergies")
        form.add_static_label('Where shall we deliver this to?')
        form.add_field(Type.SHORTSTRING, "Address", labeltext="Address") 
        form.add_static_label('Please enter your payment info:') 
        form.add_field(Type.SHORTSTRING, "PaymentInfo", labeltext="Payment Info")        
        # !!! Add any static labels or fields you want to include in this form...
        #form.add_task_label(fields=["FirstName","FoodOrder","PaymentInfo"]) 

    def get_feedback_form_creator(self, stepname, form):
        '''
        Defines the customer feedback form for the Customer application.
        This form appears once the Driver has delivered the order.
        '''
        form.add_static_label('What date did you receive your Panera order?') 
        form.add_field(Type.DATE, "Date")
        form.add_static_label('Please provide feedback regarding your Panera experience:') 
        form.add_field(Type.LONGSTRING, "Feedback")
        form.add_static_label('Rate your food (1-eh, 5-awesome): ')
        form.add_field(Type.CHOICE, "FoodFeedback",choices=['1', '2', '3', '4', '5'], labeltext="Food Feedback")
        form.add_static_label('Rate your delivery service (1-eh, 5-awesome): ')
        form.add_field(Type.CHOICE, "DeliveryFeedback",choices=['1', '2', '3', '4', '5'], labeltext="Delivery Feedback")        
        # Vanessa will add feedback form content


if __name__ == '__main__':
    #starts up the CustomerApplication:
    app = CustomerApplication()
    #Start interacting with the user:
    app.MainLoop()